unit DM;

interface

uses
  SysUtils, Classes, DB, DBAccess, Uni, MemDS, IniFiles, Forms, UniProvider,
  SQLServerUniProvider;

type
  TdmSEO = class(TDataModule)
    conSEO: TUniConnection;
    qrExecSQL: TUniQuery;
    pvSQL: TSQLServerUniProvider;
    procedure DataModuleCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure initConnection;
  end;

var
  dmSEO: TdmSEO;

implementation

uses AES;

{$R *.dfm}

procedure TdmSEO.DataModuleCreate(Sender: TObject);
begin
  initConnection;
end;

procedure TdmSEO.initConnection;
var
  iniFile: TIniFile;
begin
  iniFile := TIniFile.Create(ExtractFileDir(Application.ExeName) + '\set.ini');
  try
    if conSEO.Connected then
      conSEO.Disconnect;
    conSEO.ProviderName := 'SQL Server';
    conSEO.Server := DecryptString(iniFile.ReadString('Connection', 'server', ''));
    conSEO.Database := DecryptString(iniFile.ReadString('Connection', 'Database', ''));
    conSEO.Username := DecryptString(iniFile.ReadString('Connection', 'User', ''));
    conSEO.Password := DecryptString(iniFile.ReadString('Connection', 'Password', ''));
    conSEO.Connect;
  finally
    iniFile.Free;
  end;
end;

end.
